<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta name="layout" content="main"/>
    <title>Edit Account</title>
  </head>
  <body>
    <div class="nav">
      <span class="menuButton"><a class="home" href="${resource(dir: '')}">Home</a></span>
      <span class="menuButton"><g:link class="list" action="list">Account List</g:link></span>
      <span class="menuButton"><g:link class="create" action="create">New Account</g:link></span>
    </div>
    <div class="body">
      <h1>Edit Account</h1>
      <g:if test="${flash.message}">
        <div class="message">${flash.message}</div>
      </g:if>
      <g:hasErrors bean="${accountInstance}">
        <div class="errors">
          <g:renderErrors bean="${accountInstance}" as="list"/>
        </div>
      </g:hasErrors>
      <g:form method="post">
        <input type="hidden" name="id" value="${accountInstance?.id}"/>
        <input type="hidden" name="version" value="${accountInstance?.version}"/>
        <div class="dialog">
          <table>
            <tbody>

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="balance">Balance:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: accountInstance, field: 'balance', 'errors')}">
                  <input type="text" id="balance" name="balance" value="${fieldValue(bean: accountInstance, field: 'balance')}"/>
                </td>
              </tr>

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="reference">Reference:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: accountInstance, field: 'reference', 'errors')}">
                  <input type="text" id="reference" name="reference" value="${fieldValue(bean: accountInstance, field: 'reference')}"/>
                </td>
              </tr>

              <tr class="prop">
                <td valign="top" class="name">
                  <label for="transactions">Transactions:</label>
                </td>
                <td valign="top" class="value ${hasErrors(bean: accountInstance, field: 'transactions', 'errors')}">

                  <ul>
                    <g:each var="t" in="${accountInstance?.transactions?}">
                      <li><g:link controller="transaction" action="show" id="${t.id}">${t?.encodeAsHTML()}</g:link></li>
                    </g:each>
                  </ul>
                  <g:link controller="credit" params="['account.id':accountInstance?.id]" action="create">Add Credit</g:link>
                  |
                  <g:link controller="deposit" params="['account.id':accountInstance?.id]" action="create">Add Deposit</g:link>

                </td>
              </tr>

              %{--<tr class="prop">
                 <td valign="top" class="name">
                     <label for="amount">Amount:</label>
                 </td>
                 <td valign="top" class="value ${hasErrors(bean:accountInstance,field:'amount','errors')}">
                     <input type="text" id="amount" name="amount" value="${fieldValue(bean:accountInstance,field:'amount')}" />
                 </td>
             </tr> --}%

            </tbody>
          </table>
        </div>
        <div class="buttons">
          <span class="button"><g:actionSubmit class="save" value="Update"/></span>
          <span class="button"><g:actionSubmit class="delete" onclick="return confirm('Are you sure?');" value="Delete"/></span>
        </div>
      </g:form>
    </div>
  </body>
</html>
